package com.cyandpos.pad.pay.presenter;


import com.cyandpos.pad.pay.model.IPayCashCardModel;
import com.cyandpos.pad.pay.model.PayCashCardModelImpl;
import com.cyandpos.pad.pay.view.IPayCardCashView;
import com.cyandpos.pad.posdata.GetValueCardResponse;

/**
 * Created by Administrator on 2017/5/9.
 */

public class PayCashCardPresenter {
    private IPayCashCardModel payCashCardModel;
    private IPayCardCashView payCardCashView;

    public PayCashCardPresenter(IPayCardCashView payCardCashView){
        this.payCardCashView = payCardCashView;
        payCashCardModel = new PayCashCardModelImpl();
    }

    /**
     * 储值卡查询
     * @param type
     * @param conValue
     * @param password
     * @param verifiedCode
     */
    public void getCashCard(String type, String conValue, String password, String verifiedCode) {
        payCardCashView.showProgress("正在查询储值卡,请稍后...");
        payCashCardModel.loadCashCardData(type, conValue, password, verifiedCode, new IPayCashCardModel.OnGetCashCardListener() {
            @Override
            public void onGetCashCardSuccess(GetValueCardResponse cashCard) {
                payCardCashView.dismissProgress();
                payCardCashView.showCashCardInfoOfSwipe(cashCard);
            }

            @Override
            public void onGetCashCardFailure(String msg) {
                payCardCashView.dismissProgress();
                payCardCashView.showLoadFailureMsg(msg);
            }
        });
    }

}
